<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_LOCALES_COLLECTION_KEY" scope="page" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" scope="page" var="LAYOUT_COLLECTION_KEY" />
<bean:size id="layoutsCollectionSize" collection="${requestScope[pageScope.LAYOUT_COLLECTION_KEY]}" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.LinkedObjectsInfoContainer" var="TYPE_PAGE" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.LinkedObjectsInfoContainer" var="TYPE_RESOURCE" />

<atleap:isUserInRole roles="core-linkedObjects-view" var="canViewLinkedObjects" />

<atleap:content identifier="information" ignore="true" />
<table cellpadding="0" cellspacing="0" border="0" class="tableView">
	<tr>
		<th>
			<atleap:message key="core.page.form.title" />
		</th>
		<td>
			<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
				<div class="readOnlyField">
					<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
					<c:if test="${empty languageTitle}">
						<c:set var="languageTitle" value="${contentLocale.identifier}" />
					</c:if>
					${languageTitle}:&nbsp;<atleap:fieldValue valueMap="${requestScope.actionPage.title}" language="${contentLocale.identifier}" complexSearch="false" />
				</div>
			</atleap:iterator>
		</td>
	</tr>
	<tr>
		<th>
			<atleap:message key="core.page.form.description" />
		</th>
		<td>
			<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
				<div class="readOnlyField">
					<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
					<c:if test="${empty languageTitle}">
						<c:set var="languageTitle" value="${contentLocale.identifier}" />
					</c:if>
					${languageTitle}:&nbsp;<atleap:fieldValue valueMap="${requestScope.actionPage.description}" language="${contentLocale.identifier}" complexSearch="false" />
				</div>
			</atleap:iterator>
		</td>
	</tr>
	<tr>
		<th>
			<atleap:message key="core.page.form.keywords" />
		</th>
		<td>
			<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
				<div class="readOnlyField">
					<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
					<c:if test="${empty languageTitle}">
						<c:set var="languageTitle" value="${contentLocale.identifier}" />
					</c:if>
					${languageTitle}:&nbsp;<atleap:fieldValue valueMap="${requestScope.actionPage.keywords}" language="${contentLocale.identifier}" complexSearch="false" />
				</div>
			</atleap:iterator>
		</td>
	</tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.page.form.uri" /></th>
        <td><c:out value="${requestScope.actionPage.uri}" escapeXml="true" /></td>
    </tr>
    <tr>
        <th align="left" width="50%"><atleap:message key="core.actionPage.form.linkable" /></th>
        <td>
            <c:choose>
                <c:when test="${requestScope.actionPage.active}">
                    <atleap:message key="core.commons.boolean.true"/>
                </c:when>
                <c:otherwise>
                    <atleap:message key="core.commons.boolean.false"/>
                </c:otherwise>
            </c:choose>
        </td>
    </tr>
    <c:if test="${canViewLinkedObjects}">
        <tr>
            <td colspan="2" align="right">
                <atleap:rewriteUrl action="core/actionPage/view" var="thisRedirectUrl" >
                    <atleap:param name="id" value="${requestScope.actionPage.id}" />
                </atleap:rewriteUrl>
                <atleap:link action="core/linkedObjects/view?id=${requestScope.actionPage.id}&type=${TYPE_PAGE}&justView=true">
                    <atleap:param name="redirectUrl" value="${thisRedirectUrl}" />
                    <atleap:message key="core.commons.buttons.viewLinkedObjects" />
                </atleap:link>
            </td>
        </tr>
    </c:if>
</table>
	<atleap:form action="core/actionPage/callUpdate" method="GET" validateOnSubmit="false">
		<html:hidden property="id" value="${requestScope.actionPage.id}" />
        <atleap:isUserInRole roles="core-actionPage-update, core-actionPage-updateContent">
		    <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.callUpdate" /></atleap:submit>
        </atleap:isUserInRole>
		<atleap:cancel styleClass="button"><atleap:message key="core.commons.buttons.showList" /></atleap:cancel>
	</atleap:form>

<c:set var="ownerId" value="${requestScope.actionPage.id}" scope="request" />

<c:set var="isPage" value="true" scope="request" />

<atleap:isUserInRole roles="core-contentField-list">
    <%-- List of content fields for this page --%>
    <h3>
        <atleap:message key="core.contentField.list.page" />
    </h3>
    <c:set var="ownerIsAP" value="true" scope="request" />
    <tiles:get name="listContentFields" />
</atleap:isUserInRole>

<atleap:isUserInRole roles="core-sequence-list">
    <%-- List of sequences for this page --%>
    <h3>
        <atleap:message key="core.sequence.list.page" />
    </h3>
    <c:set var="ownerIsAP" value="true" scope="request" />
    <tiles:get name="listSequences" />
</atleap:isUserInRole>

<atleap:isUserInRole roles="core-menuItem-list">
    <%-- List of menu items for this page --%>
    <h3>
        <atleap:message key="core.menuItem.list" />
    </h3>
    <atleap:content identifier="menuItemListInfo" ignore="true" />
    <atleap:isUserInRole roles="core-actionPage-switchLayout">
        <c:if test="${layoutsCollectionSize> 0}">
            <div class="selectMessage">
                <atleap:message key="core.actionPage.form.selectLayout" />
            </div>
            <div class="switchSelect">
                <atleap:form action="core/actionPage/switchLayout" method="POST" validateOnSubmit="false">
                    <html:select property="layoutDefinition">
                        <html:optionsCollection  name="${pageScope.LAYOUT_COLLECTION_KEY}"
                                                 label="name" value="definition" />
                    </html:select>&nbsp;
                    <html:hidden property="actionPageId" value="${requestScope.actionPage.id}" />
                    <atleap:submit styleClass="button">
                        <atleap:message key="core.commons.buttons.refresh" />
                    </atleap:submit>
                </atleap:form>
            </div>
        </c:if>
    </atleap:isUserInRole>
    <tiles:get name="listMenuItems" />
</atleap:isUserInRole>
